package mock;

import cn.ibabygroup.cms.domainmodels.ContentTypeTree;
import cn.ibabygroup.cms.domainservices.CatagoryService;
import mock.entity.TestDataForm;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Crowhyc on 2016/5/23.
 */
public class ContentTester extends BeforeTester {
    @Autowired
    private CatagoryService service;

    private List<TestDataForm> init() {
        List<TestDataForm> testDataForms = new ArrayList<>();
        testDataForms.add(new UserLogin());
        return testDataForms;
    }

    @Test
    public void instance() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        BeforeTester beforeTester = (BeforeTester) Class.forName("mock.BeforeTester").newInstance();
        Assert.notNull(beforeTester);

    }

    @Test
    public void addCatagoryContentNum() {
        service.refreshCatagoryContents();
    }

    @Test
    public void testCascadeCountNum() {
        List<ContentTypeTree> tree = service.getContentTypeTree("0");
        int count = 0;
        for (ContentTypeTree t : tree) {
            count += t.getContentNum();
        }
        System.out.println(count);
    }

}
